<?php

namespace Wechat;

/**
 * Class WordProcess
 * @package Wechat
 */
class EventProcess {
    public $tyep;
    public $parameter=[];
    public function __construct()
    {

    }
    public function process($text){
        $result=db('weixin_autoreply')->where(['status'=>1])->order('id asc')->select();
        $res=null;
        foreach($result as $v){
            $keywords=explode(',',trim($v['keywords'],','));
            foreach($keywords as $k){
                if(strpos($k,$text) !== false){
                    $res=$v;
                    break 2;
                }
            }
        }
        if($res){
            //判断消息类型
            if(1==$res['type']){
                $this->tyep='text';
                $this->parameter=$res['reply'];
            }
            return true;
        }else{
            return false;
        }
    }
}
